/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 0;
    border-bottom: 2px solid #e0e0e0;
}

body.dark-mode .preview-header {
    border-bottom-color: #444;
}

.preview-header h1 {
    font-size: 1.8rem;
    color: #4a6fa5;
}

body.dark-mode .preview-header h1 {
    color: #81a1c1;
}

.toolbar {
    display: flex;
    gap: 10px;
}

.toolbar-btn {
    padding: 8px 16px;
    background: #4a6fa5;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.toolbar-btn:hover {
    background: #3a5a8a;
    transform: translateY(-2px);
}

body.dark-mode .toolbar-btn {
    background: #5e81ac;
}

body.dark-mode .toolbar-btn:hover {
    background: #81a1c1;
}

/* 编辑器容器 */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 140px);
}

@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .editor-panel, .preview-panel {
        height: 60vh;
    }
}

/* 面板通用样式 */
.editor-panel, .preview-panel {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.dark-mode .editor-panel,
body.dark-mode .preview-panel {
    background: #2d2d2d;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.panel-header {
    padding: 12px 15px;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
}

body.dark-mode .panel-header {
    background: #3d3d3d;
    border-bottom-color: #444;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #555;
}

body.dark-mode .panel-header h3 {
    color: #e0e0e0;
}

/* Markdown编辑器 */
.markdown-editor {
    flex: 1;
    width: 100%;
    padding: 20px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    border: none;
    resize: none;
    outline: none;
    background: transparent;
    color: inherit;
}

body.dark-mode .markdown-editor {
    color: #e0e0e0;
}

/* Markdown预览 */
.markdown-preview {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* 欢迎消息样式 */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

body.dark-mode .welcome-message {
    color: #aaa;
}

.welcome-message h2 {
    color: #4a6fa5;
    margin-bottom: 15px;
}

body.dark-mode .welcome-message h2 {
    color: #81a1c1;
}

.welcome-message p {
    margin-bottom: 15px;
}

.code-example {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

body.dark-mode .code-example {
    background: #3d3d3d;
}

.code-example p {
    font-weight: bold;
    margin-bottom: 10px;
}

/* Markdown功能提示 */
.features-panel {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85rem;
}

body.dark-mode .features-panel {
    background: #3d3d3d;
    border-top-color: #444;
}

.features-panel h4 {
    margin-bottom: 10px;
    color: #555;
    font-size: 0.9rem;
}

body.dark-mode .features-panel h4 {
    color: #e0e0e0;
}

.feature-list {
    list-style-type: none;
    padding-left: 0;
}

.feature-list li {
    margin-bottom: 5px;
    padding-left: 15px;
    position: relative;
    color: #666;
}

body.dark-mode .feature-list li {
    color: #aaa;
}

.feature-list li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #4a6fa5;
}

body.dark-mode .feature-list li:before {
    color: #81a1c1;
}

/* Markdown渲染样式 */
.markdown-preview h1 {
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1rem;
    color: #4a6fa5;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.3em;
}

.markdown-preview h2 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #4a6fa5;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.3em;
}

.markdown-preview h3 {
    font-size: 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: #4a6fa5;
}

.markdown-preview p {
    margin-bottom: 1rem;
}

.markdown-preview strong {
    font-weight: bold;
    color: #333;
}

.markdown-preview em {
    font-style: italic;
}

.markdown-preview a {
    color: #4a6fa5;
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-preview li {
    margin-bottom: 0.5rem;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 1rem 0;
}

.markdown-preview blockquote {
    border-left: 4px solid #4a6fa5;
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 1rem;
    color: #666;
    font-style: italic;
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 1.5rem 0;
}

/* 代码块样式 */
.markdown-preview pre {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
}

.markdown-preview code {
    background: #f8f9fa;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

/* 表格样式 */
.markdown-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.markdown-preview th,
.markdown-preview td {
    border: 1px solid #e0e0e0;
    padding: 0.5rem;
    text-align: left;
}

.markdown-preview th {
    background: #f0f0f0;
    font-weight: bold;
}

/* 暗色模式下的Markdown渲染样式 */
body.dark-mode .markdown-preview h1,
body.dark-mode .markdown-preview h2,
body.dark-mode .markdown-preview h3 {
    color: #81a1c1;
}

body.dark-mode .markdown-preview h1 {
    border-bottom-color: #444;
}

body.dark-mode .markdown-preview h2 {
    border-bottom-color: #444;
}

body.dark-mode .markdown-preview strong {
    color: #e0e0e0;
}

body.dark-mode .markdown-preview a {
    color: #81a1c1;
}

body.dark-mode .markdown-preview blockquote {
    color: #aaa;
    border-left-color: #81a1c1;
}

body.dark-mode .markdown-preview hr {
    border-top-color: #444;
}

body.dark-mode .markdown-preview pre,
body.dark-mode .markdown-preview code {
    background: #3d3d3d;
    color: #e0e0e0;
}

body.dark-mode .markdown-preview th,
body.dark-mode .markdown-preview td {
    border-color: #444;
}

body.dark-mode .markdown-preview th {
    background: #3d3d3d;
}

/* 代码语法高亮样式 */
.code-keyword {
    color: #0066cc;
}

.code-string {
    color: #009900;
}

.code-comment {
    color: #999;
    font-style: italic;
}

.code-function {
    color: #cc6600;
}

.code-number {
    color: #660099;
}

/* 暗色模式下的代码高亮 */
body.dark-mode .code-keyword {
    color: #569cd6;
}

body.dark-mode .code-string {
    color: #6a9955;
}

body.dark-mode .code-comment {
    color: #6a9955;
}

body.dark-mode .code-function {
    color: #dcdcaa;
}

body.dark-mode .code-number {
    color: #b5cea8;
}